﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ATM
{
    class HasCardState : State
    {
        ATM machine;
        bool passPINCheck;

        public HasCardState(ATM machine)
        {
            this.machine = machine;
        }

        public string InsertCard()
        {
            return "There is card inside the card slot";
        }

        public string EjectCard()
        {
            machine.SetState(machine.GetNoCardState());
            return "Get your card back";
        }

        public bool EnterPIN(int pin, int[] storedPins)
        {
            passPINCheck = false;//reset very time new pin entered

            if (!passPINCheck)
            {
                //Handle security
                foreach (int pinNum in storedPins)
                {
                    if (pinNum == pin)
                    {
                        passPINCheck = true;
                        machine.SetState(machine.GetHasPinState());
                    }
                }
            }

            return passPINCheck;
        }

        public bool ChooseCash()
        {
            return false;
        }

        public void ChooseTransfer()
        {
            throw new NotImplementedException();
        }

        public bool ChooseDeposite()
        {
            return false;
        }

        public bool InsertEnvelope()
        {
            return false;
        }

        public void EnterAmount()
        {
            
        }

        public void EnterAccountTarget()
        {
            throw new NotImplementedException();
        }

        public bool EnterReturnToMenu()
        {
            return false;// just cannot go to main menu directly with out PIN
        }

    }
}
